home *** CD-ROM | disk | FTP | other *** search
/ The Best of Down Under Games / The Best of Down Under Games.iso / 3dfx Screen Savers / VoodooLights / Sources / cell_tp6.c < prev    next >
C/C++ Source or Header  |  1997-07-15  |  2KB  |  109 lines

  1. /*------------------------------------------------------/
  2. /                                                        /
  3. /    Copyright 1997, SΘrgio Durte <smd@di.fct.unl.pt>    /
  4. /                                                        /
  5. /------------------------------------------------------*/
  6.  
  7.  
  8. #include <stdlib.h>
  9. #include <glide.h>
  10. #include <math.h>
  11. #include "defines.h"
  12. #include "mat.h"
  13. #include "rgb.h"
  14. #include "tex.h"
  15. #include "cam.h"
  16. #include "cell.h"
  17. #include "cell_util.h"
  18. #include "cell_tp6.h"
  19.  
  20. extern Float Time ;
  21.  
  22. static void tp6_acc_cell(Cell *c) 
  23. {
  24.     Float r = 5000.0 ;
  25.     c->acc.x = r * sin( Time * 0.41233 ) ;
  26.     c->acc.y = r * cos( -Time * 0.29432 ) ;
  27.     c->acc.z = -8000.0 ;
  28. }
  29.  
  30. static void tp6_display_cell( Cell *c )
  31. {
  32.     XYZW pos ;
  33.     GrVertex vtx0, vtx1 ;
  34.  
  35.     cam_W2P_XYZ( & c->pos, & pos ) ; 
  36.  
  37.     if( clp_PointVisible( & pos ) ) {
  38.  
  39.         if( ! clp_PointVisible( & c->lpos ) ) {
  40.             win_printf("caca da glossa") ;
  41.         }
  42.         cam_XYZW2Vertex( & pos, & vtx0 ) ;
  43.         cam_XYZW2Vertex( & c->lpos, & vtx1 ) ;
  44.     
  45.         vtx0.r = c->color.r ;
  46.         vtx0.g = c->color.g ;
  47.         vtx0.b = c->color.b ;
  48.         vtx0.a = c->color.a ;
  49.  
  50.         vtx1.r = 0.5 * c->color.r ;
  51.         vtx1.g = 0.5 * c->color.g ;
  52.         vtx1.b = 0.5 * c->color.b ;
  53.         vtx1.a = c->color.a ;
  54.  
  55.         grAADrawLine( & vtx0, &vtx1 ) ;    
  56.  
  57.         c->lpos = pos ;
  58.     } else {
  59.         cutl_random_pos( 180.0, c ) ;
  60.         cam_W2P_XYZ( & c->pos, & c->lpos ) ; 
  61.     }
  62. }
  63.  
  64. void tp6_set_glide_state( void )
  65. {
  66.     guColorCombineFunction( GR_COLORCOMBINE_ITRGB ) ;
  67.     grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_ONE, GR_COMBINE_LOCAL_CONSTANT, GR_COMBINE_OTHER_ITERATED, FXFALSE );
  68.     grAlphaBlendFunction( GR_BLEND_SRC_ALPHA, GR_BLEND_ONE_MINUS_SRC_ALPHA, GR_BLEND_ZERO, GR_BLEND_ZERO ) ;
  69. }
  70.  
  71. Cell *ctp6_Constructor( Cell *dad )
  72. {
  73.  
  74.   Cell *c = cell_Constructor( CellType6 ) ;
  75.  
  76.   c->max_speed = 20.0 ; 
  77.  
  78.  
  79.   c->dad = dad ;
  80.  
  81.   cutl_random_pos( 400.0, c ) ;
  82.   cam_W2P_XYZ( & c->pos, & c->lpos ) ; 
  83.  
  84.   c->max_chld = 0 ;
  85.   c->p_chld = 0.0 ;
  86.   c->adulthood = 1.0 ;
  87.   c->size = 2.0 ;
  88.  
  89.   c->color.r = 200.0 ;
  90.   c->color.g = 200.0 ;
  91.   c->color.b = 200.0 ;
  92.   c->color.a = 255.0 ;
  93.  
  94.   c->display_cell = tp6_display_cell ;
  95.   c->acc_cell = tp6_acc_cell ;
  96.  
  97.   return c ;
  98. }  
  99.     
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.     
  108.  
  109.